<template>
    <el-dialog :title="title" :visible.sync="dialogVisible" width="1200px" append-to-body>
        <el-form :model="queryParams" ref="queryForm" inline label-width="80px">
            <el-form-item label="通道" prop="tabstatus">
                    <el-select v-model="queryParams.tabstatus" placeholder="请选择通道" style="width: 240px">
                        <el-option v-for="item in tabstatus" :key="item.value" :label="item.label" :value="item.value"></el-option>
                    </el-select>
                </el-form-item>

            <el-form-item label=" ">
                    <el-button type="primary" icon="el-icon-search" @click="getDetail">搜索</el-button>
                    <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
                </el-form-item>
            </el-form>
        <div class="card">
            <el-table v-loading="loading" :data="tableData" row-key="id" border script>
                <el-table-column label="渠道" prop="tabstatus" min-width="80"></el-table-column>
                <el-table-column label="争议状态" prop="status" min-width="80"></el-table-column>
                <!-- <el-table-column label="争议原因" prop="reason" min-width="160"></el-table-column> -->
                <el-table-column label="争议原因" prop="reason" min-width="160">
                    <template slot-scope="scope">
                        <p>{{ scope.row.reason }}</p>
                        <!-- <el-link type="primary" @click="ReasonForDisputeDialog(scope.row)">争议原因</el-link> -->
                    </template>
                </el-table-column>
                <!-- <el-table-column label="订单号" prop="order_name">
                    <template slot-scope="scope">
                        <el-link type="primary" @click="showDetailDialog(scope.row)">{{ scope.row.order_name }}</el-link>
                    </template>
                </el-table-column> -->
                <!-- <el-table-column label="支付状态" prop="financial_status" min-width="160"></el-table-column> -->
            </el-table>
            <pagination v-show="total > 0" :total="total" :page.sync="pageInfo.page" :limit.sync="pageInfo.limit" @pagination="getList" />
        </div>
    </el-dialog>
</template>

<script>
import { Unmatcheds} from '@/api/order'
// import { getShopList } from '@/api/shop'
import { parseTime } from '@/utils/quickadmin'
export default {
    name: 'UnmatchedsDialog',
    components: {},
    props: {
        value: {
            type: Boolean,
            default: false,
            required: true,
        },
        params: {
            type: Object,
            default: () => {},
        },
    },
    data() {
        return {
            loading: true,
            tableData: [],
            total: 0,
            pageInfo: {
                page: 1,
                limit: 10,
            },
            tabstatus: [
                { label: '所有通道', value: "All" },
                { label: 'shopifyPayment', value: "shopify" },
                { label: 'afterpay', value: "afterpay" },
                { label: 'airwallex', value: "airwallex" },
                { label: 'paypal', value: "paypal" },
                { label: 'stripe', value: "stripe" },
            ],
            shopList: [],
            loading: false,
            chatList: [],
            queryParams: {
                tabstatus : "All",
            }
        }
    },
    computed: {
        title() {
            return `未匹配争议`
        },
        dialogVisible: {
            get() {
                return this.value
            },
            set(val) {
                this.$emit('input', val)
            },
        },
    },
    async created() {
        // this.loading = true
        // try {
        //     const [shopData] = await Promise.all([getShopList()])
        //     this.shopList = shopData?.data?.list ?? []
        // } catch (error) {
        //     this.loading = false
        //     console.log(error)
        // }
    },
    watch: {
        params: {
            handler(val) {
                if (val) {
                    this.queryParams = Object.assign({}, this.queryParams, val)
                }
            },
            immediate: true,
            deep: true,
        },
    },
    mounted() {
        this.getDetail()
    },
    methods: {
        changeDimension() {
            this.getDetail()
        },
        // 重置按钮操作
        resetQuery() {
            this.resetForm('queryForm')
            this.getDetail()
        },
        getDetail() {
            this.loading = true
            const qyparams = { ...this.queryParams }
            if(qyparams.createtime && qyparams.createtime.length==2) {
                qyparams.createtime = [parseTime(qyparams.createtime[0], 'y-m-d'), parseTime(qyparams.createtime[1], 'y-m-d')]; 
            }
            Unmatcheds(qyparams)
                .then(res => {
                    console.log('testres',res);
                    
                    this.tableData = res.data?.list ?? []
                    this.total = res.data?.total ?? 0
                })
                .finally(() => {
                    this.loading = false
                })
        },
    },
}
</script>

<style></style>
